<template>
<div>
	<yd-infinitescroll :callback="loadList" ref="infinitescrollDemo">
	    <yd-list theme="4" slot="list"> 
	        <yd-list-item v-for="item, key in arr" :key="key">
	            <img slot="img" :src="pic(item.top_pic)">
	            <!-- <img slot="img" :src="item.uid_headimg"> -->
	            <span slot="title">{{item.title}}</span>
	            <yd-list-other slot="other">
	                <div>
	                   型号：{{item.attr_name}}
	                </div>
	            </yd-list-other>
	            <yd-list-other slot="other">
	                <div>
	                    {{item.name}}，{{item.mobile}}，数量：{{item.num}}
	                </div>
	            </yd-list-other>
	            <yd-list-other slot="other">
	                <div>
	                    <span style="margin-top:-10px;">微信昵称：{{item.uid_nickname}}</span>
	                </div>
	            </yd-list-other>
	            <yd-list-other slot="other">
	                <div>
	                   下单时间：{{item.create_time}}
	                </div>
	            </yd-list-other>
	            
	        </yd-list-item>
	    </yd-list>

	    <!-- 数据全部加载完毕显示 -->
	    <span slot="doneTip">---------- 没有更多数据了 ----------</span>
    </yd-infinitescroll>
</div>	
</template>

<script>

import { mapGetters } from 'vuex';
import { cutImage } from '../../util/util'

export default {
	name: 'fxorderlist',
	
	data () {
		return {
		  	fxorderlist : {},
		  	pageNo: 1,
			pageSize: 10,
			arr : new Array(),
		}
	},

	components: {

		
	},

	computed : {
		...mapGetters([
			'company_code', 
			'userdata',
			'URL',
		]),
	},

	methods : {
		pic (toppic) {
			var result = this.URL.defaultImg;
			if(toppic != undefined){
				try{
					var ttt = JSON.parse(toppic);
					result = cutImage(ttt[0]);
				}catch(err){

				}
			}
			return result;
		},

		loadList () {

			const para = {
				fun : 'fxorderlist',
				fx_level : this.userdata.fx_level,
				pageNo : this.pageNo,
		  		pageSize : this.pageSize,
		  		title : this.$route.query.title,
		  		mobile : this.$route.query.mobile,
		  		name : this.$route.query.name,
		  		start_time : this.$route.query.start_time + ' 00:00:00',
		  		end_time : this.$route.query.end_time + ' 23:59:59',
				cb : res => {
					console.log(res);
					this.arr =  this.arr.concat(res.results);

					if(res.results.length < this.pageSize 
					|| this.pageNo == res.totalPage)
					{
		  				this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
		  				return;
		  			}

		  			this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');

	                this.pageNo++;
				}
			};

			this.$store.dispatch('update', para);
		},
	},

	watch:{
	    
	},

	mounted () {
		this.loadList();
	},

}
</script>

<style scoped>

</style>
